main: Drop log builtin
authorColin Walters <walters@verbum.org>
Tue, 23 Jul 2013 22:16:54 +0000 (18:16 -0400)
committerColin Walters <walters@verbum.org>
Tue, 23 Jul 2013 22:19:14 +0000 (18:19 -0400)
We may revive this later, but commits in their current form aren't
very useful for humans to read, so it doesn't make sense to have a
tool to show a history of useless stuff.

More interesting things are diffs between commits, object statistics,
etc.

Makefile-ostree.am
Makefile-tests.am
src/libotutil/ot-unix-utils.c
src/libotutil/ot-unix-utils.h
src/ostree/main.c
src/ostree/ot-builtin-log.c [deleted file]
src/ostree/ot-builtins.h
tests/test-log.sh [deleted file]

index 949641e608c5183a29d3e37d20af708a61d0101f..ee49c38e4830d8081e490a6aed19cafe44e6ef88 100644 (file)
@@ -31,7 +31,6 @@ ostree_SOURCES = src/ostree/main.c \
        src/ostree/ot-builtin-fsck.c \
        src/ostree/ot-builtin-init.c \
        src/ostree/ot-builtin-pull-local.c \
-       src/ostree/ot-builtin-log.c \
        src/ostree/ot-builtin-ls.c \
        src/ostree/ot-builtin-prune.c \
        src/ostree/ot-builtin-refs.c \
index 19764e66b56f2dd07c2779eae3e88df788ec0877..c7d9e54513fa2cb4af0508398392ad0d19474f84 100644 (file)
@@ -23,7 +23,6 @@ insttestdir=$(pkglibexecdir)/installed-tests
 testfiles = test-basic \
        test-archive \
        test-archivez \
-       test-log \
        test-remote-add \
        test-corruption \
        test-libarchive \
index 8cb1992612e972b359648db615bae43945feb031..2933d649b767df1eb4998c7de7542abfa910444d 100644 (file)
 #include <errno.h>
 #include <dirent.h>
 
-gboolean
-ot_util_spawn_pager (GOutputStream  **out_stream,
-                     GError         **error)
-{
-  gboolean ret = FALSE;
-  const char *pager;
-  char *argv[2];
-  int stdin_fd;
-  pid_t pid;
-  gs_free GOutputStream *ret_stream = NULL;
-
-  if (!isatty (1))
-    {
-      ret_stream = (GOutputStream*)g_unix_output_stream_new (1, TRUE);
-    }
-  else
-    {
-      pager = g_getenv ("GIT_PAGER");
-      if (pager == NULL)
-        pager = "less";
-      
-      argv[0] = (char*)pager;
-      argv[1] = NULL;
-      
-      if (!g_spawn_async_with_pipes (NULL, argv, NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
-                                     NULL, NULL, &pid, &stdin_fd, NULL, NULL, error))
-        {
-          g_prefix_error (error, "%s", "Failed to spawn pager: ");
-          goto out;
-        }
-      
-      ret_stream = (GOutputStream*)g_unix_output_stream_new (stdin_fd, TRUE);
-    }
-
-  ot_transfer_out_value(out_stream, &ret_stream);
-  ret = TRUE;
- out:
-  return ret;
-}
-
 gboolean
 ot_util_filename_validate (const char *name,
                            GError    **error)
index ed15379fb2a1572095d492c4e9b705ed17f7c02a..aba997fe34871c4076b078f90e1bfa5f23863eaa 100644 (file)
@@ -36,8 +36,6 @@
 
 G_BEGIN_DECLS
 
-gboolean ot_util_spawn_pager (GOutputStream  **out_stream, GError         **error);
-
 void ot_util_fatal_literal (const char *msg) G_GNUC_NORETURN;
 
 void ot_util_fatal_gerror (GError *error) G_GNUC_NORETURN;
index b20cdbb0e9c3f157b507c113615e6c6500e92784..580fc8e2c93fb8d43c96a9cbc09b4d59ccf2650f 100644 (file)
@@ -40,7 +40,6 @@ static OstreeCommand commands[] = {
   { "diff", ostree_builtin_diff, 0 },
   { "fsck", ostree_builtin_fsck, 0 },
   { "init", ostree_builtin_init, 0 },
-  { "log", ostree_builtin_log, 0 },
   { "ls", ostree_builtin_ls, 0 },
   { "refs", ostree_builtin_refs, 0 },
   { "prune", ostree_builtin_prune, 0 },
diff --git a/src/ostree/ot-builtin-log.c b/src/ostree/ot-builtin-log.c
deleted file mode 100644 (file)
index a5e9715..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
- *
- * Copyright (C) 2011 Colin Walters <walters@verbum.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Author: Colin Walters <walters@verbum.org>
- */
-
-#include "config.h"
-
-#include "ot-builtins.h"
-#include "ostree.h"
-
-static GOptionEntry options[] = {
-  { NULL }
-};
-
-gboolean
-ostree_builtin_log (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
-{
-  GOptionContext *context;
-  gboolean ret = FALSE;
-  const char *rev;
-  gs_unref_object OstreeRepo *repo = NULL;
-  gs_unref_object GOutputStream *pager = NULL;
-  gs_unref_variant GVariant *commit = NULL;
-  gs_free char *resolved_rev = NULL;
-
-  context = g_option_context_new ("- Show revision log");
-  g_option_context_add_main_entries (context, options, NULL);
-
-  if (!g_option_context_parse (context, &argc, &argv, error))
-    goto out;
-
-  if (argc < 2)
-    {
-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
-                   "A revision must be specified");
-      goto out;
-    }
-                   
-  rev = argv[1];
-
-  repo = ostree_repo_new (repo_path);
-  if (!ostree_repo_check (repo, error))
-    goto out;
-
-  if (!ot_util_spawn_pager (&pager, error))
-    goto out;
-
-  if (!ostree_repo_resolve_rev (repo, rev, FALSE, &resolved_rev, error))
-    goto out;
-
-  while (TRUE)
-    {
-      char *formatted = NULL;
-      GVariant *parent_csum_v = NULL;
-      const char *subject;
-      const char *body;
-      guint64 timestamp;
-      GVariant *content_csum_v = NULL;
-      GVariant *metadata_csum_v = NULL;
-      GDateTime *time_obj = NULL;
-      char *formatted_date = NULL;
-      const char *body_newline;
-      gsize bytes_written;
-      GVariant *commit_metadata = NULL;
-      char *formatted_metadata = NULL;
-      
-      g_clear_pointer (&commit, (GDestroyNotify) g_variant_unref);
-      if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, resolved_rev, &commit, error))
-        goto out;
-
-      /* Ignore commit metadata for now */
-      g_clear_pointer (&commit_metadata, (GDestroyNotify) g_variant_unref);
-      g_clear_pointer (&parent_csum_v, (GDestroyNotify) g_variant_unref);
-      g_clear_pointer (&content_csum_v, (GDestroyNotify) g_variant_unref);
-      g_clear_pointer (&metadata_csum_v, (GDestroyNotify) g_variant_unref);
-      g_variant_get (commit, "(@a{sv}@ay@a(say)&s&st@ay@ay)",
-                     &commit_metadata, &parent_csum_v, NULL, &subject, &body,
-                     &timestamp, &content_csum_v, &metadata_csum_v);
-      timestamp = GUINT64_FROM_BE (timestamp);
-      time_obj = g_date_time_new_from_unix_utc (timestamp);
-      formatted_date = g_date_time_format (time_obj, "%a %b %d %H:%M:%S %Y %z");
-      g_date_time_unref (time_obj);
-      time_obj = NULL;
-
-      g_clear_pointer (&commit_metadata, (GDestroyNotify) g_variant_unref);
-      formatted = g_strdup_printf ("commit %s\nSubject: %s\nDate: %s\nMetadata: %s\n\n",
-                                   resolved_rev, subject, formatted_date, formatted_metadata);
-      g_free (formatted_metadata);
-      g_free (formatted_date);
-      formatted_date = NULL;
-      
-      if (!g_output_stream_write_all (pager, formatted, strlen (formatted), &bytes_written, NULL, error))
-        {
-          g_free (formatted);
-          goto out;
-        }
-      g_free (formatted);
-      
-      body_newline = strchr (body, '\n');
-      do {
-        gsize len;
-        if (!g_output_stream_write_all (pager, "    ", 4, &bytes_written, NULL, error))
-          goto out;
-        len = body_newline ? body_newline - body : strlen (body);
-        if (!g_output_stream_write_all (pager, body, len, &bytes_written, NULL, error))
-          goto out;
-        if (!g_output_stream_write_all (pager, "\n\n", 2, &bytes_written, NULL, error))
-          goto out;
-        body_newline = strchr (body, '\n');
-        if (!body_newline)
-          break;
-        else
-          body_newline += 1;
-      } while (*body_newline);
-
-      if (g_variant_n_children (parent_csum_v) == 0)
-        break;
-      g_free (resolved_rev);
-      resolved_rev = ostree_checksum_from_bytes_v (parent_csum_v);
-    }
-
-  if (!g_output_stream_close (pager, NULL, error))
-    goto out;
-  ret = TRUE;
- out:
-  if (context)
-    g_option_context_free (context);
-  return ret;
-}
index 777a5e7c9ffc3a3a4332082e31cc1025e4c152d9..358ceeadd0622c6f60effc4bb5be1c097ddbd948 100644 (file)
@@ -36,7 +36,6 @@ gboolean ostree_builtin_diff (int argc, char **argv, GFile *repo_path, GCancella
 gboolean ostree_builtin_init (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
 gboolean ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
 gboolean ostree_builtin_pull_local (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
-gboolean ostree_builtin_log (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
 gboolean ostree_builtin_ls (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
 gboolean ostree_builtin_prune (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
 gboolean ostree_builtin_refs (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
diff --git a/tests/test-log.sh b/tests/test-log.sh
deleted file mode 100755 (executable)
index 7c415ff..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) 2011 Colin Walters <walters@verbum.org>
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the
-# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-
-set -e
-
-. $(dirname $0)/libtest.sh
-
-echo "1..1"
-
-setup_test_repository "bare"
-$OSTREE log test2 > $test_tmpdir/log.txt
-assert_file_has_content $test_tmpdir/log.txt "Test Commit 1"
-assert_file_has_content $test_tmpdir/log.txt "Test Commit 2"
-echo "ok log"